package com.ruoyi.logistic.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.NetworkAbnormalData;
import com.ruoyi.logistic.domain.NetworkOrderSource;
import com.ruoyi.logistic.service.INetworkAbnormalDataService;
import com.ruoyi.logistic.service.NetworkOrderSourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/network/orderSource")
@RestController
@Api(tags = "网点财务_订单来源")
public class NetworkOrderSourceController {
    @Autowired
    private NetworkOrderSourceService networkOrderSourceService;

    @ApiOperation("显示订单来源列表")
    @GetMapping("/selectAll")
    public R selectAll(){
        List<NetworkOrderSource> networkOrderSourceList = networkOrderSourceService.selectAll();
        if (networkOrderSourceList == null || networkOrderSourceList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(networkOrderSourceList);
        }
    }
    @ApiOperation("添加订单来源")
    @PostMapping("/insert")
    public R insert(@RequestBody NetworkOrderSource networkOrderSource){
        Boolean isAdd = networkOrderSourceService.insert(networkOrderSource);
        if (isAdd){
            return R.ok("添加成功");
        }else {
            return R.fail("添加失败");
        }
    }
    @ApiOperation("修改订单来源")
    @PostMapping("/update")
    public R update(@RequestBody NetworkOrderSource networkOrderSource){
        Boolean isUpdate = networkOrderSourceService.update(networkOrderSource);
        if (isUpdate){
            return R.ok("修改成功");
        }else {
            return R.fail("修改失败");
        }
    }
    @ApiOperation("删除订单来源")
    @PostMapping("/deleteById")
    public R deleteById(Integer id){
        Boolean isDelete = networkOrderSourceService.deleteById(id);
        if (isDelete){
            return R.ok("删除成功");
        }else {
            return R.fail("删除失败");
        }
    }
}
